Skip to content

compiletest: Add LineNumber newtype to avoid +1 magic here and there#150205

Merged
bors merged 1 commit intorust-lang:mainfrom
Enselic:line-no
Dec 23, 2025
Merged

compiletest: Add LineNumber newtype to avoid +1 magic here and there#150205
bors merged 1 commit intorust-lang:mainfrom
Enselic:line-no

Conversation

@Enselic
Copy link
Copy Markdown
Member

@Enselic Enselic commented Dec 20, 2025

Start small. If it works well we can increase usage bit by bit as time passes.

My main motivation for doing this is to get rid of the + 1 I otherwise have to add in #150201 on this line:

                crate::directives::line::line_directive(file, zero_based_line_no + 1, &line)

But I think this is a nice general improvement by itself.

Note that we keep using "0" to represent "no specific line" because changing to Option<LineNumber> everywhere is a very noisy and significant change. That can be changed later if wanted, but let's not do it now.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants